<?
session_start();
if(!session_is_registered("admin_login")){
header("location:index.php");
exit();
}
$bkeyword=$keyword;
?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>


<script>
function confirm_delete(member_id)
{
if(confirm("ยืนยันลบข้อมูล admin")){
location="delete_admin.php?member_id="+member_id;
}
}
function check_find(){
if(document.forms.fin.by.selectedIndex == 0)	//index of "------" is 0
	{
		alert("กรุณาเลือกช่องคนหาด้วย");
		document.forms.fin.by.focus();
		return false;
	}
	else{
	if(document.forms.fin.keyword.value == "")
	{
		alert("กรุณา keyword ในการค้นหาด้วยครับ");		//alert with appropriate message
		document.forms.fin.keyword.select();	//place cursor on the input box
		return false;
	}
	}
}
</script>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>

<body>
 <table width="95%" border="0" align="center" cellpadding="0" cellspacing="0">
        <tr>
          <td>&nbsp;</td>
        </tr>
        <tr>
          <td>ยินดีต้อนรับคุณ <?=$_SESSION["users_user"];?>&nbsp; เข้าสู่ระบบ&nbsp; <a href="logout.php">ออกจากระบบ</a></td>
   </tr>
        <tr>
          <td>&nbsp;</td>
        </tr>
      </table>
       <table width="95%" border="0" align="center" cellpadding="2" cellspacing="0">
        <tr>
          <td>&nbsp;</td>
        </tr>
        <tr>
          <td><div align="center">แสดงข้อมูลผู้ดูแลระบบ</div></td>
        </tr>
        <tr>
          <td><div align="center"><a href="form_admin.php">เพิ่มผู้ดูแลระบบ</a></div></td>
        </tr>
        <tr>
          <td><div align="center">
            <form action="" method="post" enctype="multipart/form-data" name="fin" id="fin" onSubmit="return check_find();">
              ค้นหาจาก
              <label>
<select name="by" id="by">
  <option value="0">เลือกช่องค้นหา</option>
  <option value="users_user" selected="selected">ชื่อ</option>
  <option value="users_email">อีเมล์</option>
</select>              
คำค้นหา              </label>
              <label>
              <input name="keyword" type="text" id="keyword" value="<?=$bkeyword;?>" />
              </label>
              <label>
              <input type="submit" name="Submit" value="ค้นหา" >
              </label>
            </form>
            
            </div></td>
        </tr>
        <tr>
          <td bgcolor="#FFCC66">
		    <p>
		      <?
		  include "../configdb.php";
		  if($keyword==""){	
		  $sql="select*from users ORDER BY users_user ASC";
		  }
		  else{
		  $sql="select*from users where $by like '%$keyword%'";
		   }
		  $query=mysql_db_query($dbname,$sql);
		  $numrows=mysql_num_rows($query);
		 
		 // print $numrows."<br>";
		     ?>
		    </p>
			
	        <table width="100%" border="0" cellpadding="4" cellspacing="2" bordercolor="#996633" bgcolor="#BFC4D4">
              <tr>
                <td width="6%" bgcolor="#ECBA88"><div align="center"><font size="2" face="tahoma"><b>ลำดับ</b></font></div></td>
                <td width="16%" bgcolor="#ECBA88"><div align="center"><font size="2" face="tahoma"><b>ชื่อผู้ใช้</b></font></div></td>
                <td width="18%" bgcolor="#ECBA88"><div align="center"><font size="2" face="tahoma"><b>รหัสผ่าน</b></font></div></td>
                <td width="14%" bgcolor="#ECBA88"><div align="center"><font size="2" face="tahoma"><b>ชื่อ - นามสกุล </b></font></div></td>
                <td width="14%" bgcolor="#ECBA88"><div align="center"><font size="2" face="tahoma"><b>อีเมล์</b></font></div></td>
                <td width="14%" bgcolor="#ECBA88"><div align="center"><font size="2" face="tahoma"><b>เวลาล็อกอิน</b></font></div></td>
                <td width="18%" bgcolor="#ECBA88"><div align="center"><font size="2" face="tahoma"><b>เวลาล็อกเอาท์</b></font></div></td>
                 <td width="18%" bgcolor="#ECBA88"><div align="center"><font size="2" face="tahoma"><b>เวลาล็อกเอาท์</b></font></div></td>
                  <td width="18%" bgcolor="#ECBA88"><div align="center"><font size="2" face="tahoma"><b>เวลาล็อกเอาท์</b></font></div></td>
                   <td width="18%" bgcolor="#ECBA88"><div align="center"><font size="2" face="tahoma"><b>เวลาล็อกเอาท์</b></font></div></td>
                <td width="18%" bgcolor="#ECBA88"><div align="center"><font size="2" face="tahoma"><b>แก้ไข/ลบ</b></font></div></td>
              </tr>
			  <? for($i=1;$i<=$numrows;$i++){
			  $rs=mysql_fetch_array($query);
			  $numtp=$i%2;
			  if ($numtp==0){$color="#449120";}
			  else{$color="#C1F0C9";}?>
			  
              <tr>
                <td bgcolor="<?=$color;?>"><div align="center">
                  <?=$i;?>
                </div></td>
                <td bgcolor="<?=$color;?>"><?=$rs[users_user];?></td>
                <td bgcolor="<?=$color;?>"><?=$rs[users_pass];?></td>
                <td bgcolor="<?=$color;?>"><?=$rs[users_name];?></td>
                <td bgcolor="<?=$color;?>"><?=$rs[users_position];?></td>
                <td bgcolor="<?=$color;?>"><?=$rs[users_address];?></td>
                <td bgcolor="<?=$color;?>"><?=$rs[users_tel];?></td>
                <td bgcolor="<?=$color;?>"><?=$rs[users_email ];?></td>
                <td bgcolor="<?=$color;?>"><?=thaidate($rs[users_online_date ]);?></td>
                <td bgcolor="<?=$color;?>"><?=thaidate($rs[users_logout_time]);?></td>
                <td bgcolor="<?=$color;?>"><table width="100%" border="0" cellspacing="1" cellpadding="0">
                  <tr>
                    <td><div align="center"><a href="../admin/show2edit_admin.php?member_id=<?=$rs[member_id];?>"><img src="../images/button_edit.png" alt="แก้ไข" width="12" height="13" border="0" /></a></div></td>
                    <td><div align="center"><a href="javascript:confirm_delete(<?=$rs[member_id]; ?>);"><img src="../images/button_drop.png" alt="ลบ" width="11" height="13" border="0"></a></div></td>
                  </tr>
                </table></td>
              </tr><? }?>
            </table></td>
        </tr>
        <tr>
          <td>&nbsp;</td>
        </tr>
      </table>
</body>
</html>
